package com.producteev4j.services.version0;

import com.producteev4j.exceptions.ProducteevUserException;
import com.producteev4j.model.response.BaseResponse;

/**
 * Created by IntelliJ IDEA.
 * User: jcarrey
 * Date: 18/05/11
 * Time: 10:03
 * To change this template use File | Settings | File Templates.
 */
public final class ProducteevValidator {

    //  private static final Logger logger = Logger.getLogger(ProducteevValidator.class);

    private ProducteevValidator() {
    }

    public static <T extends BaseResponse> T assertNoError(T response) throws ProducteevUserException {
        if (response.isError()) {
            // logger.warn("Error fetching:" + response.getError().getRequest() + " \n Message : " + response.getError().getMessage());
            throw new ProducteevUserException(response.getError().getRequest(), response.getError().getMessage());
        }
        return response;
    }

}
